var path = require('path');
const CompressionPlugin = require('compression-webpack-plugin');
const resolve = function (dir) {
    return path.join(__dirname, dir);
};
module.exports = {
    publicPath: './',
    lintOnSave: false,
    productionSourceMap: false,
    outputDir: 'dist',
    devServer: {
        proxy: {
            '/gateway/': {
                target: 'http://123.139.156.125:37081/',
                changeOrigin: true,
                pathRewrite: {
                    '^/gateway/': ''
                }
            }
        }
    },
    configureWebpack: config => {
        return {
            plugins: [
                new CompressionPlugin({
                    algorithm: 'gzip',
                    test: /\.(js|css)$/, // 匹配文件名
                    threshold: 10240, // 对超过10k的数据压缩
                    deleteOriginalAssets: false, // 不删除源文件
                    minRatio: 0.8 // 压缩比
                })
            ]
        };
    },
    chainWebpack: config => {
        config.module
            .rule('compile')
            .test(/\.js$/)
            .include.add(resolve('src'))
            .add(resolve('node_modules/cloud-module-base/packages'))
            .add(resolve('node_modules/cloud-module-base/static/js'))
            .end()
            .use('babel')
            .loader('babel-loader')
            .options({
                presets: [
                    [
                        '@babel/preset-env',
                        {
                            modules: false
                        }
                    ]
                ]
            });
        config.resolve.alias
            .set('@', resolve('src'))
    },
    pages: {
        maneuver: {
            entry: 'src/pages/maneuver/main.js',
            template: 'index.html',
            filename: 'index.html'
        }
    }
};
